package com.ellecity06.cwhiskymall.adapter

import androidx.fragment.app.FragmentPagerAdapter
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import java.util.*

/**
 * @author zavier
 * @time 2024/10/22 15:03
 * @des TODO
 */
class MyFragmentPagerAdapter(fm: FragmentManager, private val fragments: List<Fragment>, private val titles: Array<String>? = null) :
    FragmentPagerAdapter(fm) {


    override fun getItem(position: Int): Fragment {
        return fragments[position]
    }

    override fun getCount(): Int {
        return fragments.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return if (titles == null) {
            ""
        } else titles[position]
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        super.destroyItem(container, position, `object`)
    }

    override fun notifyDataSetChanged() {
        super.notifyDataSetChanged()
    }

    override fun getItemPosition(`object`: Any): Int {
        return super.getItemPosition(`object`)
    }
}